﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using K3R.Logic;

namespace K3R.Web.ControlExtensions {
	public static class Extension {
		public static int SelectedIntegerValue(this DropDownList ddl) {
			int rv;
			int.TryParse(ddl.SelectedValue, out rv);
			return rv;
		}

		public static string ToYesNo(this bool value) {
			return value ? "Yes" : "No";
		}

		public static string WithoutDefault(this TextBox textBox, string defaultValue) {
			return textBox.Text.Replace(defaultValue, "").Trim();
		}

		public static void BindCountryCodes(this DropDownList ddl, bool optional) {
			CountryCode.BindDropDownList(ddl, optional);
		}

		public static void BindCountryCodes(this DropDownList ddl, string defaultValue) {
			CountryCode.BindDropDownList(ddl, defaultValue);
		}

		public static void BindCountryCodes(this DropDownList ddl) {
			CountryCode.BindDropDownList(ddl);
		}

		public static void BindStateCodes(this DropDownList ddl, bool optional) {
			StateCode.BindDropDownList(ddl, optional);
		}

		public static void BindStateCodes(this DropDownList ddl, string defaultValue) {
			StateCode.BindDropDownList(ddl, defaultValue);
		}

		public static void BindStateCodes(this DropDownList ddl) {
			StateCode.BindDropDownList(ddl);
		}
	}
}
